package com.syni.mdd.yhd.common.all.listen.user;

import com.alibaba.fastjson.JSON;
import com.syni.mdd.yhd.common.all.constants.AuroraPushCode;
import com.syni.mdd.yhd.common.all.constants.Constants;
import com.syni.mdd.yhd.common.all.entity.*;
import com.syni.mdd.yhd.common.all.entity.user.BmsUser;
import com.syni.mdd.yhd.common.all.listen.groupBuy.GroupBuyEvent;
import com.syni.mdd.yhd.common.all.service.*;
import com.syni.mdd.yhd.common.all.utils.*;
import com.syni.mdd.yhd.common.all.utils.aurora.AuroraMessageUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * @className OrderListener
 * @description TOO
 * @Author cfx
 * @DATE 2019/8/8 15:46
 * @VERSION 1.0
 **/
@Component
public class UseRegisterListener implements ApplicationListener<UserRegisterEvent> {
    private final Logger log = LoggerFactory.getLogger(getClass());

    @Override
    @Async
    public void onApplicationEvent(UserRegisterEvent userRegisterEvent) {
        log.info("___________________注册用户____________________________");
        BmsUser bmsUser = userRegisterEvent.getBmsUser();
        Integer roleId = userRegisterEvent.getRoleId();
        //注册极光聊天
        if(roleId == Constants.GENERAL_USER_ROLE_ID){
            AuroraMessageUtils.registerGeneralUsers(bmsUser);
        }else if(roleId == Constants.BUSINESS_ROLE_ID){
            //AuroraMessageUtils.registerBusinessUsers(bmsUser);
        }
    }
}
